package com.sxit.tdf.server.config;

import cn.dev33.satoken.stp.StpInterface;
import com.sxit.tdf.server.mapper.UserMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.ArrayList;
import java.util.List;
import java.util.Set;

/**
 * @author 橙子高
 * @date 2022/2/6 12:15
 * @describe
 */
@Component
public class StpInterfaceImpl implements StpInterface {

  @Autowired private UserMapper userMapper;

  /** 返回一个账号所拥有的权限码集合 */
  @Override
  public List<String> getPermissionList(Object loginId, String loginType) {
    String id = String.valueOf(loginId);
    Set<String> permissions = userMapper.searchUserPermission(id);
    return new ArrayList<>(permissions);
  }

  /** 返回一个账号所拥有的角色标识集合 (权限与角色可分开校验) */
  @Override
  public List<String> getRoleList(Object o, String s) {
    // 因为本项目不需要用到角色判定，所以这里就返回一个空的ArrayList对象

    ArrayList<String> list = new ArrayList<String>();
    return list;
  }
}
